package com.acme;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

public class BankClient {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try(Socket socket = new Socket("localhost", 9900)) {
            try(DataInputStream dis = new DataInputStream(socket.getInputStream());
            DataOutputStream dos = new DataOutputStream(socket.getOutputStream())) {
                String message;
                while (true) {
                    message = sc.nextLine();
                    dos.writeUTF(message);
                    if ("exit".equals(message)) {
                        break;
                    }
                    System.out.println(dis.readUTF());
                }
            } catch(IOException e) {
                e.printStackTrace();
            }
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}
